home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 58 / pcpp58a.iso / extras / quake 3 source / Q3A_ToolSource.exe / Main / CharBuffer.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-02  |  2.3 KB  |  89 lines

  1. #ifndef __CHARBUFFER_HPP
  2. #define __CHARBUFFER_HPP
  3.  
  4. class CCharBuffer
  5. {
  6.     char* m_pCharBuffer;
  7.     unsigned m_uSize;
  8.   
  9.   public:
  10.     CCharBuffer();
  11.  
  12.     CCharBuffer(unsigned uSize);
  13.   
  14.     CCharBuffer(const char* pString);
  15.   
  16.     CCharBuffer(const CCharBuffer& rhs);
  17.   
  18.    ~CCharBuffer();
  19.  
  20.     char* Allocate(uint uSize);
  21.  
  22.     void DeAllocate();
  23.  
  24.     size_t StringLength()
  25.       { return strlen(m_pCharBuffer); }
  26.   
  27.     void StripTrailing(char c, int nLen);
  28.   
  29.     char& operator *()
  30.       { return *m_pCharBuffer; }
  31.   
  32.     char& operator *() const
  33.       { return *const_cast<CCharBuffer*>(this)->m_pCharBuffer; }
  34.   
  35.     operator void*()
  36.       { return m_pCharBuffer; }
  37.   
  38.     operator char*()
  39.       { return m_pCharBuffer; }
  40.   
  41.     operator const char*()
  42.       { return reinterpret_cast<const char*>(m_pCharBuffer); }
  43.   
  44.     operator unsigned char*()
  45.       { return reinterpret_cast<unsigned char*>(m_pCharBuffer); }
  46.   
  47.     operator const unsigned char*()
  48.       { return reinterpret_cast<const unsigned char*>(m_pCharBuffer); }
  49.   
  50.     unsigned SizeOf()
  51.       { return m_uSize; }
  52.   
  53.     CCharBuffer& operator =(const CCharBuffer& rhs);
  54.   
  55.     CCharBuffer& operator =(const char* pString);
  56.   
  57.     bool operator ==(const CCharBuffer& rhs) const
  58.       { return strcmp(m_pCharBuffer, rhs.m_pCharBuffer) == 0; }
  59.   
  60.     bool operator ==(char* pString) const
  61.       { return strcmp(m_pCharBuffer, pString) == 0; }
  62.   
  63.     bool operator ==(const char* pString) const
  64.       { return strcmp(m_pCharBuffer, pString) == 0; }
  65.   
  66.     bool operator !=(CCharBuffer& rhs) const
  67.       { return strcmp(m_pCharBuffer, rhs.m_pCharBuffer) != 0; }
  68.   
  69.     bool operator !=(char* pString) const
  70.       { return strcmp(m_pCharBuffer, pString) != 0; }
  71.   
  72.     bool operator !=(const char* pString) const
  73.       { return strcmp(m_pCharBuffer, pString) != 0; }
  74.   
  75.     char& operator [](int nIndex)
  76.       { return m_pCharBuffer[nIndex]; }
  77.   
  78.     char& operator [](int nIndex) const
  79.       { return m_pCharBuffer[nIndex]; }
  80.   
  81.     char* Fill(char FillChar)
  82.       { memset(m_pCharBuffer, FillChar, m_uSize-1); return m_pCharBuffer; }
  83. };
  84. //
  85. //-----------------------------------------------------------------------------
  86. #endif // __CCHARBUFFER_HPP
  87. //-----------------------------------------------------------------------------
  88. //
  89.